package cn.gson.springboot.model.pojos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Date;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

@Entity
@Table(name = "businesstrip_", schema = "crm")
public class Businesstrip {
    private int businessId;
    private String businessTheme;
    private Date businessStartDate;
    private Date businessEndDate;
    private String businessDestination;//目的地
    private Integer businessVehicle;//交通工具
    private BigDecimal businessMoney;// 借款
    private Integer businessClassify;// 状态
    private String businessRemarks;
    private String businessPeer;// 同行人
    private Integer businessAppStatus;
    private List<Approval> approvalsByBusinessId;
    private List<ApprovalRecord> approvalRecordsByBusinessId;
    private Opportunity opportunityByOppId;
    private Customer customerByCustomerId;
    private Employee employeeByEmpId;
    private Employee employeeByAppEmpId;// 审批人

    @Id
    @Column(name = "business_id", nullable = false)
    public int getBusinessId() {
        return businessId;
    }

    public void setBusinessId(int businessId) {
        this.businessId = businessId;
    }


    @Basic
    @Column(name = "business_theme", nullable = true, length = 255)
    public String getBusinessTheme() {
        return businessTheme;
    }

    public void setBusinessTheme(String businessTheme) {
        this.businessTheme = businessTheme;
    }

    @Basic
    @Column(name = "business_start_date", nullable = true)
    public Date getBusinessStartDate() {
        return businessStartDate;
    }

    public void setBusinessStartDate(Date businessStartDate) {
        this.businessStartDate = businessStartDate;
    }

    @Basic
    @Column(name = "business_end_date", nullable = true)
    public Date getBusinessEndDate() {
        return businessEndDate;
    }

    public void setBusinessEndDate(Date businessEndDate) {
        this.businessEndDate = businessEndDate;
    }

    @Basic
    @Column(name = "business_destination", nullable = true, length = 255)
    public String getBusinessDestination() {
        return businessDestination;
    }

    public void setBusinessDestination(String businessDestination) {
        this.businessDestination = businessDestination;
    }

    @Basic
    @Column(name = "business_vehicle", nullable = true)
    public Integer getBusinessVehicle() {
        return businessVehicle;
    }

    public void setBusinessVehicle(Integer businessVehicle) {
        this.businessVehicle = businessVehicle;
    }

    @Basic
    @Column(name = "business_money", nullable = true, precision = 2)
    public BigDecimal getBusinessMoney() {
        return businessMoney;
    }

    public void setBusinessMoney(BigDecimal businessMoney) {
        this.businessMoney = businessMoney;
    }

    @Basic
    @Column(name = "business_classify", nullable = true)
    public Integer getBusinessClassify() {
        return businessClassify;
    }

    public void setBusinessClassify(Integer businessClassify) {
        this.businessClassify = businessClassify;
    }

    @Basic
    @Column(name = "business_remarks", nullable = true, length = 255)
    public String getBusinessRemarks() {
        return businessRemarks;
    }

    public void setBusinessRemarks(String businessRemarks) {
        this.businessRemarks = businessRemarks;
    }

    @Basic
    @Column(name = "business_peer", nullable = true, length = 255)
    public String getBusinessPeer() {
        return businessPeer;
    }

    public void setBusinessPeer(String businessPeer) {
        this.businessPeer = businessPeer;
    }

    @Basic
    @Column(name = "business_app_status", nullable = true, length = 255)
    public Integer getBusinessAppStatus() {
        return businessAppStatus;
    }

    public void setBusinessAppStatus(Integer businessAppStatus) {
        this.businessAppStatus = businessAppStatus;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Businesstrip that = (Businesstrip) o;
        return businessId == that.businessId &&
                Objects.equals(businessTheme, that.businessTheme) &&
                Objects.equals(businessStartDate, that.businessStartDate) &&
                Objects.equals(businessEndDate, that.businessEndDate) &&
                Objects.equals(businessDestination, that.businessDestination) &&
                Objects.equals(businessVehicle, that.businessVehicle) &&
                Objects.equals(businessMoney, that.businessMoney) &&
                Objects.equals(businessClassify, that.businessClassify) &&
                Objects.equals(businessRemarks, that.businessRemarks) &&
                Objects.equals(businessPeer, that.businessPeer);
    }

    @Override
    public int hashCode() {
        return Objects.hash(businessId, businessTheme, businessStartDate, businessEndDate, businessDestination, businessVehicle, businessMoney, businessClassify, businessRemarks, businessPeer);
    }

    @OneToMany(mappedBy = "businesstripByBusinessId",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
    public List<Approval> getApprovalsByBusinessId() {
        return approvalsByBusinessId;
    }

    public void setApprovalsByBusinessId(List<Approval> approvalsByBusinessId) {
        this.approvalsByBusinessId = approvalsByBusinessId;
    }

    @OneToMany(mappedBy = "businesstripByBusinessId",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
    public List<ApprovalRecord> getApprovalRecordsByBusinessId() {
        return approvalRecordsByBusinessId;
    }

    public void setApprovalRecordsByBusinessId(List<ApprovalRecord> approvalRecordsByBusinessId) {
        this.approvalRecordsByBusinessId = approvalRecordsByBusinessId;
    }

    @ManyToOne
    @JoinColumn(name = "opp_id", referencedColumnName = "opp_id")
    public Opportunity getOpportunityByOppId() {
        return opportunityByOppId;
    }

    public void setOpportunityByOppId(Opportunity opportunityByOppId) {
        this.opportunityByOppId = opportunityByOppId;
    }

    @ManyToOne
    @JoinColumn(name = "customer_id", referencedColumnName = "customer_id")
    public Customer getCustomerByCustomerId() {
        return customerByCustomerId;
    }

    public void setCustomerByCustomerId(Customer customerByCustomerId) {
        this.customerByCustomerId = customerByCustomerId;
    }
    @ManyToOne
    @JoinColumn(name = "emp_id", referencedColumnName = "emp_id")
    public Employee getEmployeeByEmpId() {
        return employeeByEmpId;
    }

    public void setEmployeeByEmpId(Employee employeeByEmpId) {
        this.employeeByEmpId = employeeByEmpId;
    }

    @ManyToOne
    @JoinColumn(name = "app_emp_id", referencedColumnName = "emp_id")
    public Employee getEmployeeByAppEmpId() {
        return employeeByAppEmpId;
    }

    public void setEmployeeByAppEmpId(Employee employeeByAppEmpId) {
        this.employeeByAppEmpId = employeeByAppEmpId;
    }

}
